package l2

import "sync"

type L2NetworkType struct {
	TypeName string
	Exposed  bool
}

var (
	_lockL2NetworkType = sync.RWMutex{}
	typesL2Network     = map[string]*L2NetworkType{}
)

func HasTypeL2Network(typeName string) bool {
	_lockL2NetworkType.RLock()
	_, ok := typesL2Network[typeName]
	_lockL2NetworkType.RUnlock()
	return ok
}

func NewL2NetworkType(typeName string, exposed bool) *L2NetworkType {
	t := &L2NetworkType{
		TypeName: typeName,
		Exposed:  exposed,
	}

	_lockL2NetworkType.Lock()
	typesL2Network[t.TypeName] = t
	_lockL2NetworkType.Unlock()

	return t
}

func (t *L2NetworkType) String() string {
	return t.TypeName
}
